package com.zhuiyun.educations.api.video.mapper;

import com.zhuiyun.educations.api.video.entity.Comment;
import com.zhuiyun.educations.api.video.entity.CommentDTO;
import com.zhuiyun.educations.common.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @ClassName CommentMapper
 * @Description TODO
 * @Author 杨友朋
 * @Date 2023/7/12 9:37
 **/
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    /**
    * @Author 杨友朋
    * @Description TODO 逻辑删除
    * @Date 2023/7/12 10:56
    * @Return
    * @param id
    */
    @Update("update comment set del_flag=1 where id=#{id}")
    Integer delById(Integer id);

    /**
    * @Author 杨友朋
    * @Description TODO 根据课程全查评论
    * @Date 2023/7/12 10:56
    * @Return
    * @param commentDTO
    */

    @Select("select u.user_name,u.avatar_url,c.* from user u,comment c,course_info i " +
            "where u.id=c.user_id and i.id=c.course_id and c.del_flag=0 and c.course_id=#{courseId}")
    List<CommentDTO> selectComment(CommentDTO commentDTO);
}
